package com.yy.tools.load
{
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;

	/**
	 * xml加载工具
	 * @author YY
	 * 
	 */
	public class LoaderXML
	{
		public function LoaderXML()
		{
		}
		private var _loaderConfig:URLLoader;
		private var _callback:Function;
		public function loadXml(xmlUrl:String,callback:Function):void
		{
			_callback = callback;
			_loaderConfig = new URLLoader();
			_loaderConfig.addEventListener(Event.COMPLETE, loadConfigFunc);
			_loaderConfig.load(new URLRequest(xmlUrl));
		}
		private function loadConfigFunc(e:Event):void
		{
			_loaderConfig.removeEventListener(Event.COMPLETE, loadConfigFunc);
			_loaderConfig = null;
			var temp:XML = new XML(e.target.data);
			_callback(temp);
			_callback = null;
		}
	}
}